require(['jgGrid', 'bootstrap', 'underscore'], function () {
	var webRoot = G_WEB_ROOT;
	var urls = {
		queryPcHomeData: webRoot + '/pc/queryPcHomeData'
	};
	// 搜索
	$("#searchBtn").unbind().bind("click", function () {
		var searchTxt = $("#searchTxt").val();
		var url = window.location.href;
		// var request = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('?'));
		var request = url.split("/pc/")[1];
		if (request.startsWith("pcIemt")) {
			window.location.href = webRoot + "/pc/pcHome?iemtSearchTxt=" + searchTxt;
		}
		if ((request.startsWith("pcHome")
			|| request.startsWith("pcProductList")
			)
			&& searchTxt != "") {
			$("#Ks_ProductZone").empty();
			$.post(urls.queryPcHomeData, { 'searchTxt': searchTxt }, function (rs) {
				if (null != rs) {
					$.each(rs, function (index, item) {
						Ks_ProductZone.render(item);
					});
				}
			});
		}
		if (searchTxt == "") {
			$("#Ks_ProductZone").empty();
			$.post(urls.queryPcHomeData, function (rs) {
				if (null != rs) {
					$.each(rs, function (index, item) {
						Ks_ProductZone.render(item);
					});
				}
			});
		}
	});
	$(".j-fixcenter b").unbind().bind("click", function () {
		$("#fixCenter").hide();
	});
	 //调用浮窗方法
  fixCenter();
  //当调整浏览器窗口的大小时，发生 resize 事件
$(window).resize(function(){
  //重置浮窗定位
  fixCenterGetPosition();
});
function fixCenter(){
  //获取浮窗定位
  fixCenterGetPosition();
  //获取在浮窗的元素ID
  var fid = $("#fixCenter");
  //渐变显示元素
  fid.fadeIn(600);
  //关闭按钮的点击事件
  $("#closeFixCenter").click(function(){
    //渐变隐藏元素，三秒后重新显示
    fid.fadeOut(600).delay(3000).fadeIn(600);
  });
}
function fixCenterGetPosition(){
  var fid = $("#fixCenter");
  //获取当前窗口的高度
  var h = $(window).height();
  //获取当前窗口的宽度
  var w = $(window).width();
  //计算要定位左侧距离
//   var left = (w/2) - parseInt(fid.css("width")) / 2;
  var left = w - parseInt(fid.css("width"));
  //计算要定位上侧距离
//   var top = (h/2) - parseInt(fid.css("height")) / 2;
  var top = 220;
  //设置定位距离的样式
  fid.css({"left":(left) + "px", "top": (top) + "px" });
}
});
